<?php
function user_render_profile($data){
    
          			
			?>
  <div style="max-width:700px; margin:auto">
 <div class="web_profile">
	<div class="row">
		<div class="col-md-3">
        <img src="<?php  if($data['lavatar']){echo $data['lavatar'];}else{echo $data['avatar'];} ?>" class="img-rounded img-responsive" />

 	</div>
    
	
    <div class="col-md-9">
    <h3 class="username"><a href="<?php echo url_user($data['username']); ?>">	<?php echo show_username($data['username'],$data['name']); ?></a></h3>
    <div class="description"><i class="icon-quote-left colorfa"></i>  <?php echo $data['gioithieu']; ?>  <i class="icon-quote-right colorfa"></i></div>



					 <ul class="numbers">
                        <li>VIEW<strong><?php echo $data['views']; ?></strong></li>
                     
						<li>POST<strong><?php echo $data['comments']; ?></strong></li>
                       

                    </ul>

 
      <div class="clearfix"></div>
      <Br/>
      <ul class="list-inline pull-right">
       <?php
	  if($data['facebook'] ==1){?>
      <li> <i class="icon-facebook"></i> <a href="https://www.facebook.com/<?php echo $data['facebook_id'];?>">Vist My Facebook</a> </li>
      <?php }?>
      <li>   <i class="icon-mail"></i> <?php echo $data['email']; ?></li>
		</ul>
  </div> <!-- End of col-md-9 -->
 
  
 </div> <!-- End of row  -->
  </div> <!-- End of web profile -->
  </div><!-- End of row wap_700 -->
<?php
}


function album_render_info($data){
	
?>
  <div style="max-width:700px; margin:auto">
  

<div class="web_profile">
	<div class="row">
		<div class="col-md-3">
        <img src="<?php echo $data['image']; ?>" class="img-rounded img-responsive" />

 	</div>
    
	
    <div class="col-md-9">
    <h3 class="username">	<?php echo $data['name']; ?></h3>
    <div class="description"><i class="icon-quote-left colorfa"></i>  <?php echo $data['description']; ?>  <i class="icon-quote-right colorfa"></i></div>



					 <ul class="numbers">

                        <li>VIEW<strong><?php echo $data['views']; ?></strong></li>
                       <li class="nobrdr">POST<strong><?php echo $data['posts']; ?></strong></li>

                    </ul>

 
      <div class="clearfix"></div>
      <Br/>
      <ul class="list-inline pull-right">
      <li><i class="icon-user"></i> levanvan.1986 </li>
      <li>   <i class="icon-time"></i> <?php echo time_ago($data['date_created']) ?></li>
		</ul>
  </div> <!-- End of col-md-6 -->
 
  
 </div> <!-- End of row  -->
  </div> <!-- End of web profile -->
  </div><!-- End of row wap_700 -->
<?php
}

function post_render_grid($data,$nav="",$type="", $pagerel = null){

	if(!$data){
		echo "<h1 style='text-align:center'>Không có dữ liệu</h1>";
		return;
	}

	$pagerel = $pagerel ? '&pagerel=' . $pagerel : null;
	
	if($type==""){
	
		if($_SESSION['list_news_list'] == 1) {$news_image = 'image_near_big';} else{$news_image = 'image_med';}
	
	
       
    echo "<div id=\"contentIndex\">";
	
 
   	if(count($data)==0){

   			echo "<h1 style='text-align:center'>Chưa có bài nào được đăng !</h1>";
			}else
			foreach($data as $row){
					$row['user'] = cache_get_user($row['username']);
		?>
				<div class="item">
					
					<div class="innerItem" id="innerItem-<?= $row['pid'] . '-' . $row['type']; ?>" data-href="<?= $row['pid']; ?>" data-rel="<?= $row['type']; ?>">
						<div class="innerItemHeader">
							<div class="userHeaderInfo">
								
								<p class="font12 headerUsername pull-left"><a href="<?= HOME . 'user/' . $row['username'].'/wall'; ?>"><?=$row['username'];?></a></p>
								<p class="font11 pull-right headerUsername"><i class=" icon-time"> </i><?php echo time_ago($row['date_created']); ?> - </p>
							
								<div class="clr"></div> 
							</div>
							
							
							<h3><a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><?php echo $row['title']; ?></a></h3>
							
						</div>
						<div class="clr"></div>
                    	<div class="wrap-inner-image">
                    		<?php
							if($row['type'] == 'video'){
								if(0){
									echo '<span class="video_play_icon itemImage"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></span>';
								}else{
									echo '<a class="video_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></a>';
								}
								
							}else if($row['type'] == 'image'){
								if($row['image_gif'] == 1){
									if(0){
										echo '<span class="gif_play_icon itemImage"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></span>';
									}else{
										echo '<a class="gif_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></a>';
									}
									
								}

							}
                    		?>
                            
                            <?php if(0){
								if($row['image']!=''){?>
							<img class="itemImage img-responsive" data-toggle="modal" data-target="#popupElem-innerItem-<?= $row['id'] . '-' . $row['type']; ?>" src="<?php echo $row[$news_image]; ?>" alt=""  />
                            	<?php } ?>
							<div class="urlId" style="display: none"><?= url_post($row['pid']); ?></div>
                            <?php }else{
								if($row['image']!=''){?>
							
                            	<a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><img class=" img-responsive" src="<?php echo $row['image_med']; ?>" alt=""  /></a><?php } ?>
                            <?php }?>
                            
                          
						</div>
                        <div class="clearfix"></div>
                          <?php
							if($row['sdes']!=''){
								?>
                                <div class="text">
							<?php echo nl2br($row['sdes']); ?>
                             </div>
                              <p class="textmore pull-right"><a href="<?php echo url_post($row['pid']) . $pagerel; ?>">Xem Thêm &rarr;</a></p>
                              <div class="clearfix"></div>
                             <?php
							}?>
                        
						<div class="wrapInnerItemInfo">
						
						<div class="wrapInfo">
                          	      <?php  render_grid_kd($row['pid'],$row['kd_up'],$row['kd_down'],$row['views']); ?>
                               <div class="clr  margin5"></div>
                   		</div><!-- end .itemInfo -->
						</div>
					</div><!-- end .innerItem -->
					
				</div><!-- end .item -->
                <?php
			}?>
               
               
               
               
               
           <?php    
      
       
    echo "</div>";

		 echo $nav; ?>
            
            
           
		
    <?php
	} 
	
	
}


function post_render_grid_list($data,$nav="",$type="", $pagerel = null){
	if(!$data){
	echo "<h1 style='text-align:center'>Không có dữ liệu</h1>";
	return;
}

$pagerel = $pagerel ? '&pagerel=' . $pagerel : null;

if($type==""){

	if($_SESSION['list_news_list'] == 1) {$news_image = 'image_near_big';} else{$news_image = 'image_med';}


	 
	echo "<div id=\"contentIndex\">";


	if(count($data)==0){

		echo "<h1 style='text-align:center'>Chưa có bài nào được đăng !</h1>";
	}else

		foreach($data as $row){
			$row['user'] = cache_get_user($row['username']);
		?>
				<div class="item">
					
					<div class="innerItem" id="innerItem-<?= $row['pid'] . '-' . $row['type']; ?>" data-href="<?= $row['pid']; ?>" data-rel="<?= $row['type']; ?>">
						<div class="innerItemHeader">
							<div class="userHeaderInfo">
							
								<p class="font12 headerUsername pull-left"><a href="<?= HOME . 'user/' . $row['username'].'/wall'; ?>"><?=$row['username'];?></a></p>
								<p class="font11 pull-right headerUsername"><i class=" icon-time"> </i><?php echo time_ago($row['date_created']); ?> - </p>
							
								<div class="clr"></div> 
							</div>
							
							
							<h3><a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><?php echo $row['title']; ?></a></h3>
							
						</div>
						<div class="clr"></div>
                    	<div class="wrap-inner-image">
                    		<?php
							if($row['type'] == 'video'){
								if(0){
									echo '<span class="video_play_icon itemImage"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></span>';
								}else{
									echo '<a class="video_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></a>';
								}
								
							}else if($row['type'] == 'image'){
								if($row['image_gif'] == 1){
									if(0){echo 'here';
										echo '<span class="gif_play_icon itemImage"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></span>';
									}else{
										echo '<a class="gif_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></a>';
									}
									
								}
							}
                    		?>
                            
                                        <?php if(0){
								if($row['image']!=''){?>
							<img class="itemImage img-responsive" data-toggle="modal" data-target="#popupElem-innerItem-<?= $row['id'] . '-' . $row['type']; ?>" src="<?php echo $row[$news_image]; ?>" alt=""  />
                            	<?php } ?>
							<div class="urlId" style="display: none"><?= url_post($row['pid']); ?></div>
                            <?php }else{
								if($row['image']!=''){?>
							
                            	<a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><img class=" img-responsive" src="<?php echo $row['image_med']; ?>" alt=""  /></a><?php } ?>
                            <?php }?>
                            
                          
						</div>
                        <div class="clearfix"></div>
                          <?php
							if($row['sdes']!=''){
								?>
                                <div class="text">
							<?php echo nl2br($row['sdes']); ?>
                             </div>
                              <p class="textmore pull-right"><a href="<?php echo url_post($row['pid']) . $pagerel;?>">Xem Thêm &rarr;</a></p>
                              <div class="clearfix"></div>
                             <?php
							}?>
						<div class="wrapInnerItemInfo">
						
						<div class="wrapInfo">
                                <?php  render_grid_kd($row['pid'],$row['kd_up'],$row['kd_down'],$row['views']); ?>
							<div class="clr  margin5"></div>
   							</div><!-- end .itemInfo -->
						</div>
					</div><!-- end .innerItem -->
					
				</div><!-- end .item -->
                <?php
			}?>
               
                 
               
           <?php    
      
       
    echo "</div>";

		 ?>
            
            
           
		
    <?php
	} 
	
	

}



function post_render_grid_item($data,$type=''){
	if(!$data){
		
		return;
	}
			if($type!='album'){
				if($_SESSION['list_news_list'] == 1) {$news_image = 'image_near_big';} else{$news_image = 'image_med';}
							foreach($data as $row){
							$row['user'] = cache_get_user($row['username']);
		?>
				<div class="item">
					
					<div class="innerItem" id="innerItem-<?= $row['pid'] . '-' . $row['type']; ?>" data-href="<?= $row['pid']; ?>" data-rel="<?= $row['type']; ?>">
						<div class="innerItemHeader">
							<div class="userHeaderInfo">
								<p class="font12 headerUsername pull-left"><a href="<?= HOME . 'user/' . $row['username'].'/wall'; ?>"><?=$row['username'];?></a></p>
								<p class="font11 pull-right headerUsername"><i class=" icon-time"> </i><?php echo time_ago($row['date_created']); ?> - </p>
							
								<div class="clr"></div> 
							</div>
							
							
							<h3><a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><?php echo $row['title']; ?></a></h3>
							
						</div>
						<div class="clr"></div>
                    	<div class="wrap-inner-image">
                    		<?php
							if($row['type'] == 'video'){
								if(0){
									echo '<span class="video_play_icon itemImage"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></span>';
								}else{
									echo '<a class="video_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></a>';
								}
								
							}else if($row['type'] == 'image'){
								if($row['image_gif'] == 1){
									if(0){
										echo '<span class="gif_play_icon itemImage"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></span>';
									}else{
										echo '<a class="gif_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></a>';
									}
									
								}

							}
                    		?>
                            
                                         <?php if(0){
								if($row['image']!=''){?>
							<img class="itemImage img-responsive" data-toggle="modal" data-target="#popupElem-innerItem-<?= $row['id'] . '-' . $row['type']; ?>" src="<?php echo $row[$news_image]; ?>" alt=""  />
                            	<?php } ?>
							<div class="urlId" style="display: none"><?= url_post($row['pid']); ?></div>
                            <?php }else{
								if($row['image']!=''){?>
							
                            	<a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><img class=" img-responsive" src="<?php echo $row['image_med']; ?>" alt=""  /></a><?php } ?>
                            <?php }?>
                            
                          
						</div>
                        <div class="clearfix"></div>
                          <?php
							if($row['sdes']!=''){
								?>
                                <div class="text">
							<?php echo nl2br($row['sdes']); ?>
                             </div>
                              <p class="textmore pull-right"><a href="<?php echo url_post($row['pid']) ?>">Xem Thêm &rarr;</a></p>
                              <div class="clearfix"></div>
                             <?php
							}?>
						<div class="wrapInnerItemInfo">
						
						<div class="wrapInfo">
                          	  <?php  render_grid_kd($row['pid'],$row['kd_up'],$row['kd_down'],$row['views']); ?>
            							<div class="clr  margin5"></div>
  							</div><!-- end .itemInfo -->
						</div>
					</div><!-- end .innerItem -->
					
				</div><!-- end .item -->
								<?php
							}
			}
}

function post_render_grid_item_list($data,$type=''){

	if(!$data){

		return;
	}
	if($type!='album'){
		if($_SESSION['list_news_list'] == 1) {$news_image = 'image_near_big';} else{$news_image = 'image_med';}
		foreach($data as $row){

			$row['user'] = cache_get_user($row['username']);

			?>
								<div class="item">
								
									<div class="innerItem" id="innerItem-<?= $row['pid'] . '-' . $row['type'];?>" data-href="<?= $row['pid']; ?>" data-rel="<?= $row['type']; ?>">
										<div class="innerItemHeader">
											<div class="userHeaderInfo">
												<p class="font12 headerUsername pull-left"><a href="<?= HOME . 'user/' . $row['username'].'/wall'; ?>"><?=$row['username'];?></a></p>
								<p class="font11 pull-right headerUsername"><i class=" icon-time"> </i><?php echo time_ago($row['date_created']); ?> - </p>
							
												<div class="clr"></div> 
											</div>
											
											
											<h3><a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><?php echo $row['title']; ?></a></h3>
											
										</div>
										<div class="clr"></div>
										<div class="wrap-inner-image">
										<?php
										if($row['type'] == 'video'){
											if($_SESSION['mobile'] == 0){
												echo '<span class="video_play_icon itemImage"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></span>';
											}else{
												echo '<a class="video_play_icon hoverUnderline" href="'.url_post($row['pid']) . $pagerel.'"><img src="'.BASE_URL. 'public/images/video-play-3-xxl.png" alt="video" /></a>';
											}
											
										}else if($row['type'] == 'image'){
											if($row['image_gif'] == 1){
												if($_SESSION['mobile'] == 0){
													echo '<span class="gif_play_icon itemImage"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></span>';
												}else{
													echo '<a class="gif_play_icon" href="'.url_post($row['pid']) . $pagerel.'"><img width="60" src="'.BASE_URL. 'public/images/icon-gif-play.png" alt="video" /></a>';
												}
												
											}

										}
			                    		?>
						              <?php if($_SESSION['mobile']==0){
								if($row['image']!=''){?>
							<img class="itemImage img-responsive" data-toggle="modal" data-target="#popupElem-innerItem-<?= $row['id'] . '-' . $row['type']; ?>" src="<?php echo $row[$news_image]; ?>" alt=""  />
                            	<?php } ?>
							<div class="urlId" style="display: none"><?= url_post($row['pid']); ?></div>
                            <?php }else{
								if($row['image']!=''){?>
							
                            	<a class="hoverUnderline" href="<?php echo url_post($row['pid']) . $pagerel; ?>"><img class=" img-responsive" src="<?php echo $row['image_med']; ?>" alt=""  /></a><?php } ?>
                            <?php }?>
                            
                          
						</div>
                        <div class="clearfix"></div>
                          <?php
							if($row['sdes']!=''){
								?>
                                <div class="text">
							<?php echo nl2br($row['sdes']); ?>
                             </div>
                              <p class="textmore pull-right"><a href="<?php echo url_post($row['pid']) ?>">Xem Thêm &rarr;</a></p>
                              <div class="clearfix"></div>
                             <?php
							}?>
										
										<div class="wrapInnerItemInfo">
											
											<div class="wrapInfo">
                          	 					 <?php  render_grid_kd($row['pid'],$row['kd_up'],$row['kd_down'],$row['views']); ?>
												<div class="clr  margin5"></div>
                    							</div><!-- end .itemInfo -->
										</div>
										
									</div><!-- end .innerItem -->
									
								</div><!-- end .item -->
								<?php
							}
			}
			
}

function menu_render_category(){
	$cache = new cache;
	$dt=$cache->load('menu_category');
	if(!$dt){
		$db= new db;
		$db->connect();
		$db->query('select * from category order by name asc');
		$r=$db->fetchAll();
		$dt="";
		foreach($r as $row){
		 $val="<li><a href='".url_category($row['id'],$row['alias'])."'>".$row['name']."</a></li>";
		 $dt.=$val;
		}
		$cache->save('menu_category',$dt,300);
	}
	
	echo $dt;
	return 1;
}

/*
 * Render view most day/week/month
 */
	function template_render_top_view(){
		$date = date('Y-m-d');
		$model = new Model();
		$model->where = "last_update_view = '" . $date . "'";
		$model->limit = LOAD_ITEMS;
		$model->order = 'view_day DESC';
		$model->getdata('index_post');
		$data['result_day_most_views'] = $model->fetchAll();

		?>
		<div class="rightBlock" id="rightNewThread">
						<h4 class="rightBlockTitle">
							<i class="icon-thumbs-up"></i> Xem Nhiều - 
							<a id="rightMostDayView" class="clickShowView" href="">Ngày</a><span></span>
							<a id="rightMostWeekView" class="clickShowView" href="">Tuần</a><span></span>
							<a id="rightMostMonthView" class="clickShowView" href="">Tháng</a>
						</h4>
						
						<div class="innerRightBlock" id="show_rightMostDayView">
						
						<?php if($data['result_day_most_views']){
						
						
							foreach($data['result_day_most_views'] as $day_news){
								$news = get_post($day_news['id']);
						?>
								<div class="rightItem">
									<a class="wrapRightImage" href="<?php echo url_post($day_news['id'],'viewd'); ?>">
                                    <img src="<?php if($news['image']!=''){ echo $news['image_small'] ; }else{ echo NO_IMAGE;} ?>" style="max-width:90px" alt=""></a>
									<h4>
										<a class="rightItemTitle" href="<?php echo url_post($day_news['id'],'viewd'); ?>"><?= $news['title'];?></a> 
										
									</h4>
									<span class="pull-left font11 margin-right-10"><i class=" icon-eye-open"> </i><?= k_format($news['views']); ?></span> 
									<span class="pull-left font11 margin-right-10" >
                                             <a href="" title="Khó đỡ thật" data-href='<?php echo $news['pid'] ?>' data-rel='up'  class="btn btn-xs btn-success" >
                                     		<i class="icon-thumbs-up" style="color:#fff"></i> </a> 
                                     		 <span data-href='<?php echo $news['pid'] ?>' data-rel='up'><?php echo $news['kd_up']; ?></span>
                                    </span> 
                                    <span class="pull-left font11 margin-right-10" > 
                                  			<a href="" data-href='<?php echo $news['pid'] ?>' data-rel='down' title="Đỡ phát một"  class="btn btn-xs btn-danger" >
                                            <i class="icon-thumbs-down" style="color:#fff"></i> 
                                            </a> 
                                             <span data-href='<?php echo $news['pid'] ?>' data-rel='down'><?php echo $news['kd_down']; ?></span>
                                     </span>
                                  
								
                                  
									
                               
                                    
                                    <div class="clr"></div>
								</div><!-- end .rightItem -->
						<?php 
							}
						}else{//else if ($data['result_day_most_views'])
						?>
						
							
							
						
						<?php }?>
						</div><!-- end innerRightBlock -->
							
						<div class="innerRightBlock" id="show_rightMostWeekView"></div>
						
						<div class="innerRightBlock" id="show_rightMostMonthView"></div>	
                        
                        	</div> <!-- END OF rightNewThread --><?
	}
	
	
	/*
 * Render pickup Post
 */
	function template_render_pickup(){
		$c=new cache;
		$dt=$c->load('pickup_post');
		if(!$dt){
			$db=new db;
			$db->connect();
			$db->query('select id from index_post where pick =1  order by id desc limit 0,6');
			$data=$db->fetchAll();
			foreach($data as $row){
			$dt[]=get_post($row['id']);
			}
			$c->save('pickup_post',$dt,1200);
			$db->close();
		}
		

		?>
		<div class="rightBlock" id="rightNewThread">
						<h4 class="rightBlockTitle">
							KHÓ ĐỠ ĐỀ CỬ
						</h4>
						
						<div class="innerRightBlock1">
						
						<?php if($dt){
							
							foreach($dt as $row){
								
						?>
								<div class="rightItem">
									<a class="wrapRightImage" href="<?php echo url_post($row['pid'],'pick'); ?>"><img src="<?= $row['image_small']; ?>" style="max-width:90px" alt=""></a>
									<h4>
										<a class="rightItemTitle" href="<?php echo url_post($row['pid'],'pick'); ?>"><?= $row['title'];?></a> 
										
									</h4>
									<span class="pull-left font11 margin-right-10"><i class=" icon-eye-open"> </i><?= $row['views']; ?></span> 
                                  <span class="pull-left font11 margin-right-10" >
                                             <a href="" title="Khó đỡ thật" data-href='<?php echo $news['pid'] ?>' data-rel='up'  class="btn btn-xs btn-success" >
                                     		<i class="icon-thumbs-up" style="color:#fff"></i> </a> 
                                     		 <span data-href='<?php echo $row['pid'] ?>' data-rel='up'><?php echo $row['kd_up']; ?></span>
                                    </span> 
                                    <span class="pull-left font11 margin-right-10" > 
                                  			<a href="" data-href='<?php echo $row['pid'] ?>' data-rel='down' title="Đỡ phát một"  class="btn btn-xs btn-danger" >
                                            <i class="icon-thumbs-down" style="color:#fff"></i> 
                                            </a> 
                                             <span data-href='<?php echo $row['pid'] ?>' data-rel='down'><?php echo $row['kd_down']; ?></span>
                                     </span>
							
                                   
									<div class="clr"></div>
								</div><!-- end .rightItem -->
						<?php 
							}
						}else{//else if ($data['result_day_most_views'])
						?>
						
							
							
						
						<?php }?>
						</div><!-- end innerRightBlock -->
							
						
                        
                        	</div> <!-- END OF rightNewThread --><?
	}
	
	/*
 * Render Nguoi dep
 */
	function template_render_nguoidep(){
		$c=new cache;
		$dt=$c->load('nguoidep_post');
		if(!$dt){
			$db=new db;
			$db->connect();
			$db->query('select id from index_post where cat_id =3  order by id desc limit 0,6');
			$data=$db->fetchAll();
			foreach($data as $row){
			$dt[]=get_post($row['id']);
			}
			$c->save('nguoidep_post',$dt,1200);
			$db->close();
		}
		

		?>
		<div class="rightBlock" >
						<h4 class="rightBlockTitle">
							Người đẹp
						</h4>
						
						<div class="innerRightBlock1">
						
						<?php if($dt){
							
							foreach($dt as $row){
								
						?>
								<div class="rightItem">
									<a class="wrapRightImage" href="<?php echo url_post($row['pid'],'dep'); ?>"><img src="<?= $row['image_small']; ?>" style="max-width:90px" alt=""></a>
									<h4>
										<a class="rightItemTitle" href="<?php echo url_post($row['pid'],'dep'); ?>"><?= $row['title'];?></a> 
										
									</h4>
									<span class="pull-left font11 margin-right-10"><i class=" icon-eye-open"> </i><?= $row['views']; ?></span> 
									<span class="pull-left font11 margin-right-10"><i class="icon-thumbs-up-alt"> </i><?= $row['likes']; ?></span> 
									<span class="pull-left font11 margin-right-10"><i class="icon-comments"> </i><?= $row['comments']; ?></span>
                                   <span class="pull-left font11 margin-right-10"><a class="rightItemAuthor" href="<?php echo url_user($row['username']) ?>"><i class="icon-user"> </i><?php echo $news['username'] ?></a></span>
									<div class="clr"></div>
								</div><!-- end .rightItem -->
						<?php 
							}
						}else{//else if ($data['result_day_most_views'])
						?>
						
							
							
						
						<?php }?>
						</div><!-- end innerRightBlock -->
							
						
                        
                        	</div> <!-- END OF rightNewThread --><?
	}
	
	function template_render_facebook(){
	?>
    

  
    
		<div class="rightBlock" id="rightNewThread">
						<h4 class="rightBlockTitle">
							LIKE CHÚNG TÔI TRÊN FACEBOOK
						</h4>
						
						<div class="innerRightBlock1">
                        
                        		 <div class="fb-like" data-href="http://www.facebook.com/bongdavl" data-send="true" data-width="280" data-height="100" data-show-faces="true"  ></div>             
                       
                       
							<div style="margin-top:10px; border-top:1px solid #ccc ; padding-top:10px;text-align: left;

font-family: 'Noticia Text', Times, serif;
font-size: 1.1em;
font-weight: normal;
font-style: italic;">
                            	Chào mừng bạng đến với <a href="<?php echo HOME; ?>"><b>Khodo.Info</b> </a>. Hãy Tham gia chia sẻ những tình huống, những câu truyện, video clip hài hước khó đỡ của bạn với cộng đồng chúng tôi <i class="icon-thumbs-up"></i> . <Br/><bR/>
                                
                                <a href="<?php echo UPLOAD ?>" class="btn btn-danger btn-lg btn-block"><i class="icon-thumbs-up"></i> ĐĂNG BÀI <i class="icon-cloud-upload"></i> </a>
                               <bR/>
                                 Chúc bạn có những giây phút thư giãn thoải mái tại <a href="<?php echo HOME; ?>"><b>Khó đỡ chấm Info</b> </a>.
                            </div>
								
							</div>
                        
                        	</div> <!-- END OF rightNewThread --><?
	}

	function template_render_facebook_comment(){
	?>
    

  
    
		<div class="rightBlock" id="rightNewThread">
						<h4 class="rightBlockTitle">
							Chém gió cùng khó đỡ chấm Info
						</h4>
						
						<div class="innerRightBlock1">
                        
                       
							<div style="margin-top:10px; padding-top:10px;text-align: left;

font-family: 'Noticia Text', Times, serif;
font-size: 1.1em;
font-weight: normal;
font-style: italic;">
                            	Tham gia chém gió cùng cộng đồng <a href="<?php echo HOME; ?>"><b>Khodo.Info</b> </a> <i class="icon-thumbs-up"></i> . <Br/><bR/>
                                
                                <div class="fb-comments" id="fb-comment" data-post-id="0" data-href="http://khodo.info/" data-width="300" data-num-posts="5" data-order-by="reverse_time"></div>
      
                            </div>
								
							</div>
                        
                        	</div> <!-- END OF rightNewThread --><?
	}

function template_render_album_related($data){

					if($data && $data['list_item']){
					?>
                    		
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            	<div class="rightBlock" id="rightNewThread">
						<h4 class="rightBlockTitle">
							Cùng Playlist
                             <span class="pull-right"><a href="<?php echo url_album($data['id']); ?>">Xem Hết</a></span>
						</h4>
                       
						
						<div class="innerRightBlock1">
						
						  <?php if($data['list_item']){ 
										foreach($data['list_item'] as $row){?>
								<div class="rightItem">
									<a class="wrapRightImage" href="<?php echo url_post($row['pid'],'album'); ?>">
                                    <img src="<?php if($row['image']!=''){ echo $row['image_small'];}else{ echo NO_IMAGE;} ?>" style="max-width:90px" alt=""></a>
									<h4>
										<a class="rightItemTitle" href="<?php echo url_post($row['pid'],'album'); ?>"><?= $row['title'];?></a> 
										
									</h4>
                                    <span class="pull-left font11 margin-right-10"><i class=" icon-eye-open"> </i><?= $row['views']; ?></span> 
								
                                   <span class="pull-left font11 margin-right-10"><a class="rightItemAuthor" href="<?php echo url_user($row['username']) ?>"><i class="icon-user"> </i><?php echo $row['username'] ?></a></span>
									
									<div class="clr"></div>
								</div><!-- end .rightItem -->
						<?php 
							}
						}else{//else if ($data['result_day_most_views'])
						?>
						
							
							
						
						<?php }?>
						</div><!-- end innerRightBlock -->
							
						
                        
                        	</div> <!-- END OF rightNewThread -->
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                       
                           <?php }
}
	
function render_col_right($where='',$data=''){
		if($where=='post'){
		 template_render_album_related($data);
		   echo "<Br/>";
         echo "<Br/>";
		}
		
		 template_render_facebook(); 
         echo "<Br/>";
         echo "<Br/>";
		 template_render_top_view();
		 echo "<br />";
		// template_render_pickup(); 		
         echo "<Br/>";
		  template_render_facebook_comment(); 	
		//  template_render_nguoidep(); 
		
        
}

function render_grid_kd($id,$up,$down,$view){?>
										<div class="viewInfoMetadata "><i class="icon-eye-open"> </i> <?php echo $view; ?></div>
										
	 									<div class="viewInfoMetadata ">
                                     		<a href="" title="Khó đỡ thật" data-href='<?php echo $id ?>' data-rel='up'  class="btnThumb btn btn-xs btn-success" >
                                     			<i class="icon-thumbs-up" style="color:#fff"></i> 
                                     		</a> 
                                     		 <span class="append_vote_num_up_<?php echo $id; ?>" data-href='<?php echo $id ?>' data-rel='up'><?php echo $up; ?></span>
                                     	</div>
                                   
                                   
                                   <div class="viewInfoMetadata ">
                                   			<a href="" data-href='<?php echo $id ?>' data-rel='down' title="Đỡ phát một"  class="btnThumb btn btn-xs btn-danger" >
                                            	<i class="icon-thumbs-down" style="color:#fff"></i> 
                                            </a> 
                                            
                                            <span class="append_vote_num_down_<?php echo $id; ?>" data-href='<?php echo $id ?>' data-rel='down'><?php echo $down; ?> </span>
                                 </div>
                                 <?php
}

?>